<?php if (!defined('THINK_PATH')) exit();?><script type="text/javascript">
    $(function() {
        $('#add_advert_upload').uploadify({
            'formData'     : {
                'timestamp' : '<?php echo $timestamp;?>',
                'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
            },
                'swf'      : '/Public/js/uploadify/uploadify.swf',
                'uploader' : '<?php echo U('Advert/public_upload');?>',
                'buttonText': '图片上传',
                'width'	: 70,
                'height': 26,
                'removeTimeout':0,
                'buttonClass': 'upload_button',
                'onUploadSuccess' : function(file, data, response){
                var data = $.parseJSON(data);
                if(!data.status){
                    $.messager.alert('提示信息', data.info, 'error');
                }else{
                    $('#add_advert_url').attr('value',data.url);
                    $.messager.alert('提示信息', data.info, 'info');
                }
            }
        });

        $.formValidator.initConfig({formID:"advertAddForm",theme:'App',onSuccess:advertAddUploadSave,inIframe:true});
        $("#add_apk_version").formValidator({onShow:"请输入版本号",onFocus:"版本号不能为空"}).inputValidator({min:1,max:20,empty:{leftEmpty:false,rightEmpty:false,emptyError:"版本号两边不能有空格"},onError:"版本号不能为空"});
        $("#add_apk_url").formValidator({onShow:"请上传apk",onFocus:"请上传apk"}).inputValidator({min:1,max:200,empty:{leftEmpty:false,rightEmpty:false,emptyError:"url两边不能有空格"},onError:"请上传apk"});
        $("#add_apk_descp").formValidator({onShow:"请输入描述",onFocus:"描述不能为空"}).inputValidator({min:1,max:999,onError:"描述不能为空,请确认"});
    });
    function advertAddUploadSave(){
        $.post('<?php echo U('Advert/advertAdd');?>', $("#advertAddForm").serialize(), function(data){
            if(!data.status){
                $.messager.alert('提示信息', data.info, 'error');
            }else{
                advertRefreshList();
                $.messager.alert('提示信息', data.info, 'info');
                $('#advertAddBox').dialog('close');
            }
        })
    }
</script>
<form id="advertAddForm" style="padding: 10px;">
    <table id="editBox">
        <tr>
            <td width="100" align="center">广告说明</td>
            <td>
                <input type="text" id="remark" name="info[remark]" value="" style="width: 400px; height: 20px;">
            </td>
        </tr>

        <tr>
            <td width="100" align="center">广告链接</td>
            <td>
                <input type="text" id="imghref" name="info[imghref]" value="http://" style="width: 400px; height: 20px;">
            </td>
        </tr>
        <tr>
            <td width="100" align="center">图片地址</td>
            <td><input type="text" id="add_advert_url" name="info[imgurl]"
                       value="" readonly="readonly" style="width: 450px;height: 20px;"></td>
            <td><div id="add_advert_urlTip"></div></td>
        </tr>
        <tr>
            <td width="100" align="center">上传图片</td>
            <td>
            <div id="queue"></div>
            <input id="add_advert_upload" name="add_advert_upload" type="file" multiple="false">
            </td>
        </tr>
    </table>
</form>